﻿using System.Web.Mvc;
using System.Web.Routing;
using FluentAssertions;
using MvcApplication.Areas.Area1;
using NUnit.Framework;
using T4MvcJs;

namespace T4JS.Tests
{
    [TestFixture]
    public class RoutesTest
    {
        private RouteCollection _routes;

        [SetUp]
        public void Setup()
        {
            _routes = T4Proxy.GetRoutes();
        }

        [Test]
        public void AreaRoute()
        {
            RouteHelper.AssertRoute(_routes, "~/Area1/Ar1C1", new { controller = "Ar1C1", action = "Index" });
        }

        [Test]
        public void MapUrl_ProductIndex()
        {
            RouteHelper.AssertRoute(_routes, "~/product", new { controller = "product", action = "Index" });
        }
        [Test]
        public void MapUrl_MailInd()
        {
            RouteHelper.AssertRoute(_routes, "~/mail/Ind", new { controller = "product", action = "Ind" });
        }


        [Test]
        public void GetUrl_Custom()
        {
            var url = RouteHelper.GetUrlFor(_routes, "Product", "Ind");

            url.Should().BeEquivalentTo("/mail/Ind");
        }


        [Test]
        public void GetUrl_Home_Index()
        {
            var url = RouteHelper.GetUrlFor(_routes, "Home", "");

            url.Should().BeEquivalentTo("/");
        }
        [Test]
        public void GetUrl_Home_Indd()
        {
            var url = RouteHelper.GetUrlFor(_routes, "Home", "Indd");

            url.Should().BeEquivalentTo("/home/indd");
        }
    }
}